package com.zl.common.enums.resp;

/**
 * 通用应答码
 * @author Administrator
 *
 */
public enum GlobalRespEnum implements IRespEnum{
    /** 成功*/
    SUCCESS("global_success", "成功"),
    /** 失败*/
    ERROR("global_error", "失败"),
    /** 主键重复*/
    DUPLICATE_PRIMARY_KEY("global_duplicate_primary_key", "主键重复"),
    /** 主键获取失败*/
    ERROR_PRIMARY_KEY("global_error_primary_key", "获取主键序号失败"),
    /** 数据库不支持*/
    DATABASE_NOT_SUPPORTED("global_database_not_supported", "不支持的数据库"),
    /** 数据库连接失败*/
    DATABASE_CONNECT_FAILED("global_database_connect_failed", "数据库连接失败"),
    /** 方法未实现*/
    METHOD_NOT_IMPLEMENTED("global_method_not_implemented","方法未实现"),
    /** 文件不存在*/
    MISSING_FILE("global_missing_file", "文件不存在"),
    /** 非法参数*/
    INVALID_PARAMETER("global_invalid_parameter","参数校验未通过"),
    /** 缺失参数*/
    MISSING_PARAMETER("global_missing_parameter","缺失必要参数"),
    /** 数据已过期，请刷新*/
    DATA_IS_EXPIRED("global_data_has_expired","数据已过期，请刷新"),
    /** 数据已删除，请刷新*/
    DATA_IS_DELETED("global_data_is_deleted","数据已删除，请刷新"),
    /** 不允许删除*/
    DELETION_NOT_ALLOWED("delete_not_allowed", "数据使用中，不允许删除"),
    
    /** 无权限*/
    UNAUTHORIZED("global_unauthorized", "无权限访问"),
    /** 未找到页面*/
    NOT_FOUND("global_not_found", "未知的页面"),
    /** Token无效*/
    TOKEN_INVALID_EXCEPTION("global_token_invalid_exception", "Token无效"),
    
    SystemException("SystemException", "系统异常"),
    HttpMessageNotReadableException("HttpMessageNotReadableException", "请求JSON结构错误"),
    DataFormatException("DataFormatException", "数据格式不正确"),
    IllegalArgumentException("IllegalArgumentException","参数不符合要求"),
    MissingServletRequestParameter("MissingServletRequestParameter","缺少ServletRequest请求数据"),
    TypeMismatchException("TypeMismatchException","请求数据类型不匹配"),
    RequestMethodNotAllowed("RequestMethodNotAllowed ","http请求方式不正确"),
    ;
    private String code;
    private String msg;

    GlobalRespEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    @Override
    public String getCode() {
        return code;
    }
    @Override
    public String getMsg() {
        return msg;
    }
    
    public static String msg(String code) {
        for (GlobalRespEnum m : GlobalRespEnum.values()) {
            if (m.getCode().equalsIgnoreCase(code)) {
                return m.getMsg();
            }
        }
        return null;
    }
}